package cn.ylg.com.baisibudeijie.mvp.view.impl;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;

import cn.ylg.com.baisibudeijie.mvp.presenter.impl.MvpBasePresenter;
import cn.ylg.com.baisibudeijie.mvp.view.MvpView;

/**
 * Created by MyPC on 2016/10/18.
 */
public  abstract  class MvpFrament<P extends MvpBasePresenter> extends Fragment implements MvpView{
    protected  P presenter;
    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        //当view创建成功之后需要绑定;
        if (presenter!=null){
            presenter.attach(this);
        }
    }
    public abstract  P bindPresenter();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (presenter!=null){
            presenter.deattach();
        }
    }
}
